#pragma once

#include <iostream>
#include <string>

class Task
{
private:
    int _one;
    int _two;
    char _oper;
public:
    Task(int one = 0, int two = 0, char oper = '+')
        :_one(one), _two(two), _oper(oper)
    {}

    int run()
    {
        int result = 0;
        switch(_oper)
        {
        case '+':
             result = _one + _two;
             break;
        case '-':
             result = _one - _two;
             break;
        case '*':
             result = _one * _two;
             break;
        case '/':
             if (_two == 0)
             {
                 std::cout << "div zero, abort" <<std::endl;
                 result = -1;
             }
             else 
             {
                result = _one / _two;
             }
             break;
        case '%':
             if (_two == 0)
             {
                 std::cout <<"mod zero ,abort" << std::endl;
                 result = -1;
             }
             else 
             {
                result = _one % _two;
             }
             break;
        default:
             std::cout <<"非法操作" <<std::endl;
        }
        return result;
    }

    void get(int* e1, int *e2, char* op)
    {
        *e1 = _one;
        *e2 = _two;
        *op = _oper;
    }
};
